/**
 * 
 */
package org.jenkon.commons.io.comparator;

import java.io.File;
import java.util.Comparator;

/**
 * {@link Comparator} to compare two {@link File} objects of the last modified.
 * 
 * @author Jens Konopka
 * 
 */
public class LastModifiedFileComparator implements Comparator<File> {

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
	public int compare(final File left, final File right) {
		final long result = left.lastModified() - right.lastModified();
		if (result < 0) {
			return -1;
		} else if (result > 0) {
			return 1;
		} else {
			return 0;
		}
	}

}
